import request from '@/utils/request'
import { apiVersion } from '../config'

//  创建组件
export function addModule (data) {
  return request({
      url: `/canvas/${apiVersion}/module/create`,
      method: 'post',
      data
  })
}
//  删除组件
export function delModule (data) {
  return request({
      url: `/canvas/${apiVersion}/module/delete/${data.id}`,
      method: 'delete',
      data
  })
}
//  获取组件列表
export function getModule (data) {
  return request({
      url: `/canvas/${apiVersion}/module/list`,
      method: 'get',
      data
  })
}
//  更新组件
export function putModule (data) {
  return request({
      url: `/canvas/${apiVersion}/module/update/${data.id}`,
      method: 'put',
      data
  })
}
//  更新组件当前版本
export function putCurrentVersion (data) {
  return request({
      url: `/canvas/${apiVersion}/module/updateCurrentVersion/${data.id}`,
      method: 'put',
      data
  })
}
//  创建组件版本
export function addCurrentVersion (data) {
  return request({
      url: `/canvas/${apiVersion}/module/version/create`,
      method: 'post',
      data
  })
}
//  创建组件版本
// export function delCurrentVersion (data) {
//   return request({
//       url: `/canvas/${apiVersion}/module/version/create`,
//       method: 'post',
//       data
//   })
// }
//  删除组件版本
export function delVersion (data) {
  return request({
      url: `/canvas/${apiVersion}/module/version/delete/${data.id}`,
      method: 'delete',
      data
  })
}
//  更新组件版本
export function putVersion (data) {
  return request({
      url: `/canvas/${apiVersion}/module/version/update/${data.id}`,
      method: 'put',
      data
  })
}
//  获取canvas分页列表
export function getCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas`,
      method: 'get',
      data
  })
}
//  创建canvas
export function addCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/add`,
      method: 'post',
      data
  })
}
//  修改canvas
export function putCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/update`,
      method: 'put',
      data
  })
}
//  删除canvas
export function delCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/delete/${data.id}`,
      method: 'delete',
      data
  })
}
//  获取画布基本信息
export function getCanvasDetail (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/${data.id}`,
      method: 'get',
      data
  })
}
//  导出模型
export function exportCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/export-model`,
      method: 'put',
      data
  })
}
//  获取资源使用率(平均)
export function usageAverage (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/pod/${data.podId}/usage/${data.resourceType}/average`,
      method: 'get',
      data
  })
}
//  启动canvas容器
export function startCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/start/${data.id}`,
      method: 'put',
      data
  })
}
//  启动canvas容器
export function stopCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/stop/${data.id}`,
      method: 'put',
      data
  })
}






//  初始化画布
export function initCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/init`,
      method: 'post',
      data
  })
}
//  获取kernel信息
export function kernelCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/kernel/${data.kernelId}`,
      method: 'post',
      data
  })
}
//  中断kernel
export function interruptKernelCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/kernel/${data.kernelId}/interrupt`,
      method: 'delete',
      data
  })
}
//  重启kernel
export function restartKernelCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/kernel/${data.kernelId}/restart`,
      method: 'post',
      data
  })
}
//  获取notebook内容
export function notebookContent (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/notebookContent`,
      method: 'post',
      data
  })
}
//  保存画布内容
export function saveContentCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/saveContent`,
      method: 'post',
      data
  })
}
//  获取jupyter服务器状态
export function serverStatusCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/serverStatus`,
      method: 'post',
      data
  })
}
//  创建session
export function sessionCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/session`,
      method: 'post',
      data
  })
}
//  补充kernel信息
export function kernelSpecCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/session/kernelSpec/${data.sessionId}`,
      method: 'post',
      data
  })
}
//  删除session
export function delSessionCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/session/${data.sessionId}`,
      method: 'delete',
      data
  })
}
//  执行指定cell的代码
export function executeCellIndexCanvas (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/session/${data.sessionId}/execute/${data.cellIndex}`,
      method: 'post',
      data
  })
}
//  获得session列表
export function sessionsLis (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/sessions`,
      method: 'post',
      data
  })
}
//  获取画布全部信息
export function canvasAll (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/${data.id}/all`,
      method: 'get',
      data
  })
}
//  运行所有算子
export function canvasRunAll (data) {
  return request({
      url: `/canvas/${apiVersion}/canvas/session/${data.sessionId}/executeAll`,
      method: 'post',
      data
  })
}
